export default {
	methods: {
		machineMergeColMethod({ row, _rowIndex, column, visibleData }) {
			if (row.productionLineName) {
				const prevRow = visibleData[_rowIndex - 1];
				let nextRow = visibleData[_rowIndex + 1];
				if (column.property === 'productionLineName') {
					if (prevRow && prevRow.productionLineName === row.productionLineName && prevRow.processName === row.processName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow.productionLineName === row.productionLineName && nextRow.processName === row.processName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'productModels') {
					if (prevRow && prevRow.productModels && prevRow.productModels === row.productModels) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow.productModels && nextRow.productModels === row.productModels) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'machineName') {
					if (prevRow && prevRow.machineName === row.machineName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow.machineName === row.machineName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'processTotalOutputKg') {
					/**
					 * @mergeProcessCode 用于合并"班次"
					 * */
					if (prevRow && prevRow.processTotalOutputKg === row.processTotalOutputKg && prevRow.mergeProcessCode === row.mergeProcessCode) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow.processTotalOutputKg === row.processTotalOutputKg && nextRow.mergeProcessCode === row.mergeProcessCode) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'rotateSpeed') {
					if (prevRow && prevRow && prevRow.rotateSpeed === row.rotateSpeed && prevRow.machineName === row.machineName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow && nextRow.rotateSpeed === row.rotateSpeed && nextRow.machineName === row.machineName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'avgElectricity') {
					if (prevRow && prevRow && prevRow.avgElectricity === row.avgElectricity && prevRow.machineName === row.machineName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow && nextRow.avgElectricity === row.avgElectricity && nextRow.machineName === row.machineName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'avgEnergy') {
					if (prevRow && prevRow && prevRow.avgEnergy === row.avgEnergy && prevRow.machineName === row.machineName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow && nextRow.avgEnergy === row.avgEnergy && nextRow.machineName === row.machineName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'energy') {
					if (prevRow && prevRow && prevRow.energy === row.energy && prevRow.machineName === row.machineName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow && nextRow.energy === row.energy && nextRow.machineName === row.machineName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'machineOutputKg') {
					if (prevRow && prevRow && prevRow.machineOutputKg === row.machineOutputKg && prevRow.machineName === row.machineName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow && nextRow.machineOutputKg === row.machineOutputKg && nextRow.machineName === row.machineName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				} else if (column.property === 'empName') {
					if (prevRow && prevRow.empName && prevRow.empName === row.empName) {
						return { rowspan: 0, colspan: 0 };
					} else {
						let countRowspan = 1;
						while (nextRow && nextRow.empName && nextRow.empName === row.empName) {
							nextRow = visibleData[++countRowspan + _rowIndex];
						}
						if (countRowspan > 1) {
							return { rowspan: countRowspan, colspan: 1 };
						}
					}
				}
			}
		}
	}
};
